package com.lhj.springboot.actuator.component;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author lhj
 * @Date 2024/7/23 20:50
 */
@Slf4j
@Component
public class MyHealthComponent {

    Counter counter = null;
    
    public MyHealthComponent(MeterRegistry meterRegistry) {
        this.counter = meterRegistry.counter("hello.count");
    }

    public  int check(){
        //业务代码判断这个组件是否该是存活状态
        return 1;
    }

    public ResponseEntity<?> helloCount() {
        log.info("helloCount");
        counter.increment();
        return ResponseEntity.ok().build();
    }
}
